package com.yixiu.study.juc.threadpool;

import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @CalssName T04_ScheduledPool
 * @Description
 * @Author yixiu
 * @Date 2021/6/29 10:56
 * @Verison 1.0
 **/
public class T04_ScheduledPool {

    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(4);
        service.scheduleAtFixedRate(() -> {
            try {
                TimeUnit.MILLISECONDS.sleep(new Random().nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());

        }, 0, 1, TimeUnit.SECONDS);

    }

}
